import axios from "axios"
// import { MessageBox, Message } from "element-ui"
import store from "@/store"
import { getToken } from "@/utils/auth";
//  create axios
const service = axios.create({
  baseURL: process.env.VUE_STUDENT_API, // 请求的根路径 url = base url + require url
  timeout: 5000 //请求时间
})

// 请求拦截
service.interceptors.request.use(
  config => {
    if (store.getters.token) {
      config.headers['Bearer'] = getToken()
    }
    return config
  },
  error => {
    console.log(error) // for debug
    return Promise.reject(error)
  }
)

// 响应拦截
service.interceptors.response.use(

  // 对响应数据做点什么
)

export default service
